////////////////////////////////////////////////////////////////////////////////
//
//  FLYING KIWI BV
//  Copyright 2010 Flying Kiwi BV
//  All Rights Reserved.
//
//  NOTICE: Flying Kiwi permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package plantool.helpers {
	import flash.text.AntiAliasType;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	import kiwi.utils.Validation;

	//--------------------------------------------------------------------------
	//  Imports
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  [Metadata (Events, Style, Effects etc)]
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  Class declaration
	//--------------------------------------------------------------------------
	public class TextFieldHelper {
		//--------------------------------------------------------------------------
		//Class constants
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class variables
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class properties
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//FONTS
		//--------------------------------------------------------------------------
//		[Embed(source="D:/Projecten/Flying Kiwi/Plantool 3.0/src/fonts/title.ttf", fontFamily="TitleFont", embedAsCFF="false")] 
//		public var TitleFont:Class;
//		[Embed(source="D:/Projecten/Flying Kiwi/Plantool 3.0/src/fonts/info.ttf", fontFamily="InfoFont", embedAsCFF="false")] 
//		public var InfoFont:Class;
		
		//--------------------------------------------------------------------------
		//Constructor and Destructor
		//--------------------------------------------------------------------------
		public function TextFieldHelper() {
		}
		
		//--------------------------------------------------------------------------
		//Class methods
		//--------------------------------------------------------------------------
		private static function createTextfield(format:TextFormat, selectable:Boolean = false, mouseEnabled:Boolean = false):TextField {
			//create the textfield
			var textfield:TextField		= new TextField();
			textfield.antiAliasType		= AntiAliasType.ADVANCED;
			textfield.defaultTextFormat	= format;
			textfield.selectable		= selectable;
			textfield.mouseEnabled		= mouseEnabled;
			
			return textfield;
		}
		
		public static function createTitleTf(autoSize:String = TextFieldAutoSize.LEFT, align:String = TextFormatAlign.LEFT, italic:Boolean = true, multiline:Boolean = false, color:Number = 0xFFFFFF):TextField {
			//create the font-format
			var format:TextFormat		= new TextFormat();
			format.font					= "Verdana";
			format.size					= 13;
			format.color				= color;
			format.bold					= true;
			format.align				= align;
			
			//create the textfield
			var textfield:TextField		= createTextfield(format);
			textfield.multiline			= multiline;
			textfield.autoSize			= autoSize;
			textfield.text				= "Title Textfield";
			textfield.height			= textfield.getLineMetrics(0).height + 4;
			
			//return the create textfield
			return textfield;
		}
		
		public static function createInfoTf(autoSize:String = TextFieldAutoSize.LEFT, align:String = TextFormatAlign.LEFT, italic:Boolean = true, multiline:Boolean = false, color:Number = 0xFFFFFF):TextField {
			//create the font-format
			var format:TextFormat		= new TextFormat();
			format.font					= "Verdana";
			format.italic				= italic;
			format.size					= 10;
			format.align				= align;
			format.color				= color;
			
			//create the textfield
			var textfield:TextField		= createTextfield(format);
			textfield.multiline			= multiline;
			textfield.autoSize			= autoSize;
			textfield.text				= "Info Textfield";
			textfield.height			= textfield.textHeight + 4;
			
			//return the create textfield
			return textfield;
		}
		
		public static function createInputTf(multiline:Boolean = false):TextField {
			//create the font-format
			var format:TextFormat		= new TextFormat();
			format.font					= "Verdana";
			format.italic				= false;
			format.size					= 10;
			format.color				= 0xFFFFFF;
			
			//create the textfield
			var textfield:TextField		= createTextfield(format, true, true);
			textfield.multiline			= multiline;
			textfield.autoSize			= TextFieldAutoSize.NONE;
			textfield.width				= 300;
			textfield.text				= "Input Textfield";
			textfield.height			= textfield.textHeight + 4;
			
			textfield.type 				= TextFieldType.INPUT;
			textfield.border			= true;
			textfield.borderColor		= 0x999999;
			textfield.background		= true;
			textfield.backgroundColor	= 0xDDDDDD;
			
			//return the create textfield
			return textfield;
		}
	}
}